using Holoville.HOTween;
using Holoville.HOTween.Core;
using I2.Loc;
using UnityEngine;

public class DevConsoleSelectAchievement : MonoBehaviour
{
	public Achievement achievement;

	public UISprite icon;

	public new UILabel name;

	public UILabel goal;

	public UIInput progressLeft;

	public UILabel progressRight;

	private GameObject selected;

	public void Select(Achievement ach)
	{
		achievement = ach;
		icon.spriteName = ach.achievementIcon;
		name.text = ScriptLocalization.Get("Achivments/" + ach.achievementNameID + "_Title");
		goal.text = ScriptLocalization.Get("Achivments/" + ach.achievementNameID + "_Description");
		progressLeft.value = ach.currentCount.ToString();
		progressLeft.UpdateLabel();
		progressRight.text = " / " + ach.neededCount;
	}

	public void ApplyProgress()
	{
		int value = int.Parse(progressLeft.value);
		int num = Mathf.Clamp(value, 0, achievement.neededCount);
		achievement.Increment(num - achievement.currentCount);
		progressLeft.value = num.ToString();
		progressLeft.UpdateLabel();
		selected.GetComponent<DevConsoleAchievement>().Refresh();
	}

	public void RevertAchievement()
	{
		achievement.Unset();
		achievement.Init();
		selected.GetComponent<DevConsoleAchievement>().Refresh();
		progressLeft.value = achievement.currentCount.ToString();
		progressLeft.UpdateLabel();
	}

	public void PlaySelect(GameObject newItem)
	{
		if (selected != null)
		{
			HOTween.To(selected.transform, 0.3f, new TweenParms().Prop("localScale", Vector3.one).OnComplete((TweenDelegate.TweenCallback)delegate
			{
				selected = newItem;
			}));
		}
		else
		{
			selected = newItem;
		}
		HOTween.To(newItem.transform, 0.3f, new TweenParms().Prop("localScale", Vector3.one * 1.5f));
	}
}
